/*
 * @Author: 陈俊升 761723995@qq.com
 * @Date: 2023-05-11 18:11:41
 * @LastEditors: 陈俊升 761723995@qq.com
 * @LastEditTime: 2024-02-28 11:26:55
 * @FilePath: /hr_new_vue3/src/apis/management/human/humanChange/leave/index.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
/* 工作台api */

import { ajaxService } from '@/utils/request';

const env = import.meta.env;
// const baseURL = env.VITE_API_BASE_URL;
const baseURL = env.VITE_DEV_BASE_URL;
const baseURL2 = env.VITE_APP_BASE_URL;

/**
 * 获取工作台页面排列顺序
 * userId: 员工id
 */
export function GetWorkPlaceSort(params: { userId: number }) {
  return ajaxService({
    url: '/hr/workbench/sort',
    method: 'get',
    baseURL: baseURL,
    params
  });
}

/**
 * 新增工作台页面排列顺序
 * userId: 员工id
 * sorts : 排序
 * {
    key: 对应移动模块的key;
    name: 对应移动模块的name;
 }
 */
export function PostWorkPlaceSort(data: { userId: number; sorts: string }) {
  return ajaxService({
    url: '/hr/workbench/sort',
    method: 'post',
    baseURL: baseURL,
    data
  });
}

/**
 * 修改工作台页面排列顺序
 * userId: 员工id
 * sorts : 排序
 * {
    key: 对应移动模块的key;
    name: 对应移动模块的name;
 }
 */
export function PutWorkPlaceSort(data: {
  id: number;
  userId: number;
  sorts: string;
}) {
  return ajaxService({
    url: '/hr/workbench/sort',
    method: 'put',
    baseURL: baseURL,
    data
  });
}

/**
 * 获取日程待办
 * date: 日期(例如2024-01-01)
 */
export function GetSchedule2Do(params: { id: number; date: string }) {
  return ajaxService({
    url: '/hr/workbench/calendar',
    method: 'get',
    baseURL: baseURL,
    params
  });
}
// 发起日程待办
export function PostSchedule2Do(data: any) {
  return ajaxService(
    {
      url: '/hr/workbench/calendar',
      method: 'post',
      baseURL: baseURL,
      data
    },
    {
      mode: 'success',
      message: '新增成功！'
    }
  );
}

// 修改日程待办
export function PutSchedule2Do(data: any) {
  return ajaxService(
    {
      url: '/hr/workbench/calendar',
      method: 'put',
      baseURL: baseURL,
      data
    },
    {
      mode: 'success',
      message: '修改成功！'
    }
  );
}

// 发起日程待办
export function DelSchedule2Do(params: { id: number }) {
  return ajaxService(
    {
      url: '/hr/workbench/calendar',
      method: 'delete',
      baseURL: baseURL,
      params
    },
    {
      mode: 'success',
      message: '删除成功！'
    }
  );
}

/**
 * 修改工作台个性标签或个人档案人才标签
 * @params
 * type: 1个性标签 2人才标签
 * id: 人员id
 * text: 标签id，用逗号隔开
 * @returns
 */
export function PutHumanTag(data: { id: number; type: 1 | 2; text: string }) {
  return ajaxService(
    {
      url: '/hr/personnel_matters/roster/tip',
      method: 'put',
      baseURL: baseURL,
      data
    },
    {
      mode: 'success',
      message: '修改成功！'
    }
  );
}
